class CreateSites < ActiveRecord::Migration
  def self.up
    create_table :sites, :options => 'ENGINE=InnoDB DEFAULT CHARSET=UTF8' do |t|
      t.column :name, :string, :null => false
      t.column :home_page, :string, :null => false
      t.column :url_pattern, :string
      t.column :image, :string
      t.column :rss, :string
      t.column :approved, :boolean, :null => false
      t.column :is_im, :boolean, :null => false
      t.column :created_at, :datetime
    end
    
    foreign_key(:identities, :site_id, :sites)
    
    Site.create(:name => "MSN", :home_page => "http://www.msn.com", :approved => true, :is_im => true,
                :image => "#{Configuration.default_online_status_provider}/msn/$")
    Site.create(:name => "Yahoo Messenger", :home_page => "http://messenger.yahoo.com", :approved => true, :is_im => true,
                :image => "#{Configuration.default_online_status_provider}/yahoo/$")
    Site.create(:name => "Skype", :home_page => "http://www.skype.com", :approved => true, :is_im => true,
                :image => "http://mystatus.skype.com/smallclassic/$")
    Site.create(:name => "QQ", :home_page => "http://www.qq.com", :approved => true, :is_im => true,
                :image => "http://wpa.qq.com/pa?p=1:$:5", :url_pattern => "http://$.qzone.qq.com")
  end
  
  def self.down
    remove_foreign_key(:identities, :site_id)
    drop_table :sites
  end
end
